package com.web.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import com.web.servlet.bean.GameInfo;
import com.web.servlet.bean.RedisKey;
import com.web.servlet.bean.TableInfo;
import com.web.servlet.manager.GameServerMananger;
import com.web.servlet.manager.RedisManager;
/**
 * 游戏信息及版本信息
 * @author davie.yu
 *
 */
public class PlatformVersionServlet extends HttpServlet {
	private static final long serialVersionUID = 8581970247778309577L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request,response);
	}
	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		response.setContentType("text/plain");
		response.setCharacterEncoding("utf-8");
		
		PrintWriter out = response.getWriter();
		
		
		
		
		
		
		//平台 默认　gameID 1
		int gameId = 1;
		GameInfo info = GameServerMananger.getGameInfoByID(gameId);
		if(null != info){
			Document document = DocumentHelper.createDocument();
	    	Element rootElement = document.addElement("root");
			rootElement.addAttribute("v", info.getGame_version());//平台版本
			rootElement.addAttribute("purl", info.getGame_url());//平台下载版本
			rootElement.addAttribute("av", info.getAndroid_version());//andrid apk版本
			rootElement.addAttribute("ad", info.getAndroid_url());//andrid DownApk
			rootElement.addAttribute("iv", info.getIos_version());//ios ipa版本
			rootElement.addAttribute("id", info.getIos_url());//ios DownIPa
			
			
			rootElement.addAttribute("v", "1.0");//平台版本
			rootElement.addAttribute("purl", "127.0.0.1/web");//平台下载版本
			rootElement.addAttribute("av", "1.0");//andrid apk版本
			rootElement.addAttribute("ad", "127.0.0.1/andrid");//andrid DownApk
			rootElement.addAttribute("iv", "1.0");//ios ipa版本
			rootElement.addAttribute("id", "127.0.0.1/ios");//ios DownIPa
			
	    	out.print(document.asXML());
			out.flush();
			out.close();
		}
	}


}
